<?php
/**
 * 房源条件
 */

namespace app\official\controller;


use app\common\controller\Official;
use app\official\model\IntervalConfig as IntervalConfigModel;
use app\official\model\Metro;
use app\official\model\Region as RegionModel;
use think\Exception;

class Where extends Official {

    /**
     * 省市区和条件
     * @return false|string
     */
    public function getList() {
        try {
            $params = $this->checkParams('city_code');
            if ($params === false) {
                return $this->resErr();
            }
            $area_list = RegionModel::getArea($params['city_code']);//市下面的区域
            $price_interval = IntervalConfigModel::allIntervel($params['city_code'])['price_interval'];//价格区间
            $discount_interval = IntervalConfigModel::allIntervel($params['city_code'])['discount_interval'];//折扣区间
            $build_area_interval = IntervalConfigModel::allIntervel($params['city_code'])['build_area_interval'];//面积区间
            $orderby = IntervalConfigModel::$orderby;//排序
            $a_status = IntervalConfigModel::$a_status_;//拍卖状态
            $a_type = IntervalConfigModel::$a_type;//拍卖阶段
            $bedroom = IntervalConfigModel::$bedroom;//户型
            $metro = Metro::getList($params);//地铁
            return $this->resData('success', compact('area_list', 'metro', 'price_interval', 'discount_interval', 'a_status', 'a_type', 'bedroom', 'orderby', 'build_area_interval'));
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

}
